package com.mysoft.gfyx.marketdevelop.controller;

import com.mysoft.framework.mvc.api.Controller;
import com.mysoft.framework.rpc.annotation.PubAction;
import com.mysoft.framework.rpc.annotation.PubService;
import com.mysoft.framework.rpc.contants.RequestPrefix;
import com.mysoft.gfyx.marketdevelop.service.ProvinceAndCityService;
import com.mysoft.gfyx.marketdevelop.service.dto.ProvinceAndCityConditionDto;
import com.mysoft.gfyx.marketdevelop.service.dto.ProvinceAndCityDto;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.util.List;

@PubService(value = "/provinceAndCityPub", prefix = RequestPrefix.PUB)
public class ProvinceAndCityPubController extends Controller {
    @Resource
    private ProvinceAndCityService provinceAndCityService;

    @PubAction(value = "/getAll", method = RequestMethod.POST)
    public List<ProvinceAndCityDto> getAll() {
        return provinceAndCityService.getAll();
    }

    @PubAction(value = "/getAllWithParent", method = RequestMethod.POST)
    public List<ProvinceAndCityDto> getAllWithParent() {
        return provinceAndCityService.getAllWithParent();
    }

    @PubAction(value = "/getProvince", method = RequestMethod.POST)
    public List<ProvinceAndCityDto> getProvince(@RequestBody ProvinceAndCityConditionDto conditionDto) {
        return provinceAndCityService.getProvince(conditionDto);
    }

    @PubAction(value = "/getProvinceAndCity", method = RequestMethod.POST)
    public List<ProvinceAndCityDto> getProvinceAndCity(@RequestBody ProvinceAndCityConditionDto conditionDto) {
        return provinceAndCityService.getCityAndProvinceCode(conditionDto.getProvinceCode());
    }

    @PubAction(value = "/getByCodes", method = RequestMethod.POST)
    public List<ProvinceAndCityDto> getByCodes(@RequestBody ProvinceAndCityConditionDto conditionDto) {
        return provinceAndCityService.getByCodes(conditionDto.getProvinceCode());
    }
}
